package Modele;

import java.awt.Component;
import java.util.Random;
import java.util.Observer;
import java.util.Observable;
import java.util.ArrayList;

import Vue.Fenetre;

public class MonteCarloSimulationMulti extends Observable {

	private String CallPutFlag;
	private double S;
	private double X;
	private double r;
	private double T;
	private double b;
	private double v;
	private int nSteps;
	private int nSimulations;
	private int k;
	private int i;
	
	public int getI() {
		return i;
	}

	public void setI(int i) {
		this.i = i;
	}

	private double res;
	private double Sum;
	private double resultat1;
	


	public MonteCarloSimulationMulti() {
		this.S = 40.0;
		this.X = 50.0;
		this.r = 0.06;
		this.T = 0.5;
		this.b = 0.1;
		this.v = 0.45;
		this.nSteps = 168;
		this.nSimulations = 100000;
		this.Sum = 0;
	}
	
	public void calcule(String CallPutFlag) {
		MyCallable appel = new MyCallable(CallPutFlag, S, X, r, T, b, v, nSteps, nSimulations);
		appel.mycall();
		this.resultat1=appel.getResultat1();
		this.i=appel.getI();
		setChanged();
		notifyObservers();
	}
	
	public String getCallPutFlag() {
		return CallPutFlag;
	}

	public void setCallPutFlag(String callPutFlag) {
		CallPutFlag = callPutFlag;
	}

	public double getS() {
		return S;
	}

	public void setS(double s) {
		S = s;
	}

	public double getX() {
		return X;
	}

	public void setX(double x) {
		X = x;
	}

	public double getT() {
		return T;
	}

	public void setT(double t) {
		T = t;
	}

	public double getR() {
		return r;
	}

	public void setR(double r) {
		this.r = r;
	}

	public double getB() {
		return b;
	}

	public void setB(double b) {
		this.b = b;
	}

	public double getV() {
		return v;
	}

	public void setV(double v) {
		this.v = v;
	}

	public int getnSteps() {
		return nSteps;
	}

	public void setnSteps(int nSteps) {
		this.nSteps = nSteps;
	}

	public int getnSimulations() {
		return nSimulations;
	}

	public void setnSimulations(int nSimulations) {
		this.nSimulations = nSimulations;
	}

	public double getSum() {
		return Sum;
	}

	public void setSum(double sum) {
		Sum = sum;
	}
	
	public int getK() {
		return k;
	}

	public void setK(int k) {
		this.k = k;
	}

	public double getResultat1() {
		return resultat1;
	}

	public void setResultat1(double resultat1) {
		this.resultat1 = resultat1;
	}
	public void setRes(double res) { this.res = res; }

	public double getRes() {
		return java.lang.Math.exp((-r * T)) * (this.Sum / nSimulations);
	}

}
